<template>
    <a-form-model ref="form" :model="mdl" :rules="rules">
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label-col="labelCol" :wrapper-col="wrapperCol" :label="i18n('form.gzhAppId','公众号ID')" prop="corpId">
                    <a-input
                        :placeholder="i18n('form.gzhAppId','公众号ID','input')"
                        class="defaultWith"
                        v-model="mdl.corpId"
                    />
                </a-form-model-item>
            </a-col>
            <a-col :span="12">
                <a-form-model-item :label-col="labelCol" :wrapper-col="wrapperCol" :label="i18n('form.gzhSecretKey','公众号密钥')" prop="secret">
                    <a-input
                        :placeholder="i18n('form.gzhSecretKey','公众号密钥','input')"
                        v-model="mdl.secret"
                    />
                </a-form-model-item>
            </a-col>
        </a-row>
        <a-row :span="24">
            <a-col :span="12">
                <a-form-model-item :label-col="labelCol" :wrapper-col="wrapperCol" :label="$ti18('rxForm.name','名称')" prop="name">
                    <a-input
                        :placeholder="$ti18('rxForm.name','名称')"
                        style="display: inline-block;vertical-align: middle;"
                        v-model="mdl.name"

                    />
                </a-form-model-item>
            </a-col>
            <a-col :span="12">
                <a-form-model-item :label-col="labelCol" :wrapper-col="wrapperCol" :label="i18n('form.remarks','备注')">
                    <a-input
                        :placeholder="i18n('form.remarks','备注')"
                        class="defaultWith"
                        :rows="4"
                        v-model="mdl.description"
                    />
                </a-form-model-item>
            </a-col>
        </a-row>
    </a-form-model>
</template>

<script>
import {BaseFormModel, RxDialog, Dialog} from "@lowcode/jpaas-common-lib";
import PlatFormApi from '@/api/user/org/platForms';

export default {
    name: "PlatformsWeChatGzh",
    mixins: [BaseFormModel],
    components: {
        RxDialog
    },
    props: ["dataJson"],
    data() {
        return {
            rules: {
                name: [
                    {required: true, message: this.i18n('form.appName','请输入应用名称','input'), trigger: 'blur'},
                ],
                corpId: [
                    {required: true, message: this.i18n('form.gzhAppId','请输入公众号ID','input'), trigger: 'blur'},
                ],
                agentId: [
                    {required: true, message: this.i18n('form.appID','请输入应用ID','input'), trigger: 'blur'},
                ],
                secret: [
                    {required: true, message: this.i18n('form.gzhSecretKey','请输入公众号密钥','input'), trigger: 'blur'},
                ]
            }
        }
    },
    created() {
        if (!this.dataJson || !this.dataJson.corpId) {
            return;
        }
        this.mdl = this.dataJson;
    },
    methods: {
        i18n(name, text, key) {
            return this.$ti18(name, text, "platForms", key);
        },
        checkAndSave(callback) {
            var self_ = this;
            this.$refs.form.validate(valid => {
                if (!valid) {
                    return;
                }
                self_.checkCanSave(callback);
            });
        },
        async checkCanSave(callback) {
            this.mdl.type="1";
            callback(this.mdl);
        },
    }
}
</script>

<style scoped>

</style>